#include <iostream>
#include <string>
#include<iomanip>
using namespace std;

struct student
{
    float Chin, Math, Eng, score;
    string name;
};

float total(float a, float b, float c)
{
    return a + b + c;
}

float ave(float a[], int len)
{
    int i;
    float sub = 0;
    for (i = 0; i < len; i++)
    {
        sub += a[i];
    }
    return sub / len;
}

int main()
{
    struct student stu[10];
    struct student Max;
    struct student Min;
    float averageChin, averageMath, averageEng, averageScore;
    int len = sizeof(stu) / sizeof stu[0];

    for (int i = 0; i < len; i++)
    {
        cout << "请输入第" << i + 1 << "个学生的名字" << endl;
        cin >> stu[i].name;
        cout << "请输入第" << i + 1 << "个学生的语文成绩" << endl;
        cin >> stu[i].Chin;
        cout << "请输入第" << i + 1 << "个学生的数学成绩" << endl;
        cin >> stu[i].Math;
        cout << "请输入第" << i + 1 << "个学生的英语成绩" << endl;
        cin >> stu[i].Eng;
    }
    float chin[10], math[10], eng[10], sco[10];
    for (int i = 0; i < len; i++)
    {
        stu[i].score = total(stu[i].Chin, stu[i].Math, stu[i].Eng);
        chin[i] = stu[i].Chin;
        math[i] = stu[i].Math;
        eng[i] = stu[i].Eng;
        sco[i] = stu[i].score;
        cout << stu[i].name << "同学的语文成绩是" << stu[i].Chin << endl;
        cout << stu[i].name << "同学的数学成绩是" << stu[i].Math << endl;
        cout << stu[i].name << "同学的英语成绩是" << stu[i].Eng << endl;
        cout << stu[i].name << "同学的总成绩是" << stu[i].score << endl << endl;

    }
    averageChin = ave(chin, len);
    averageMath = ave(math, len);
    averageEng = ave(eng, len);
    averageScore = ave(sco, len);
    cout << "本班的语文平均分是：" << setprecision(4) << averageChin << endl;
    cout << "本班的数学平均分是：" << setprecision(4) << averageMath << endl;
    cout << "本班的英语平均分是：" << setprecision(4) << averageEng << endl;
    cout << "本班的总分平均分是：" << setprecision(6) << averageScore << endl << endl;

    Max = stu[0];
    Min = stu[0];
    for (int i = 0; i < len; i++)
    {
        if (Max.score < stu[i].score)
            Max = stu[i];
    }

    for (int i = 0; i < len; i++)
    {
        if (Min.score > stu[i].score)
            Min = stu[i];
    }
    cout << "总分最高的同学是" << Max.name << "他的分数是：" << Max.score << endl;
    cout << "总分最低的同学是" << Min.name << "他的分数是：" << Min.score << endl;
}